﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DTO
{
    public class Person : BaseDTO
    {
        #region Enums
        #endregion

        #region Fields
        #endregion

        #region Properties
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string CompanyName { get; set; }
        public string Name
        {
            get
            {
                return FirstName + " " + LastName;
            }
        }

        public LocationInfo Location { get; set; }

        public string Fax { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }

        public bool IsActived { get; set; }
        #endregion

        #region Constructors
        public Person () : this(0) { }
        public Person ( int id ) : base(id) { }
        #endregion

        #region Public Methods
        public override string ToString()
        {
            string result = "";
            result += this.Name;
            result += (!string.IsNullOrEmpty(this.Email) ? " ( <a href='mailto:" + this.Email + "'>" + this.Email + "</a> )" : "");

            if ( Location != null )
            {
                result += ( !string.IsNullOrEmpty(this.Location.Address) ? "<br />" + this.Location.Address : "" );
                result += ( !string.IsNullOrEmpty(this.Location.Street) ? ", " + this.Location.Street : "" );
                result += ( !string.IsNullOrEmpty(this.Location.City) ? "<br />" + this.Location.City : "" );

                if (this.Location.State != null)
                    result += ( !string.IsNullOrEmpty(this.Location.State.Name) ? ", " + this.Location.State.Name : "" );

                result += ( !string.IsNullOrEmpty(this.Location.ZipCode) ? ", " + this.Location.ZipCode : "" );

                if (this.Location.Country != null)
                    result += ( !string.IsNullOrEmpty(this.Location.Country.Name) ? "<br />" + this.Location.Country.Name : "" );
            }

            result += (!string.IsNullOrEmpty(this.Phone) ? "<br />" + this.Phone : "");
            return result;
        }

        #endregion
    }
}
